package datastructure;

/**
 * @author XY
 * @version 1.0
 * @date 2022/2/10 9:21
 * @Description
 */
public class Leet125 {

    public static boolean isPalindrome(String s) {
        if(s.equals("")){
            return true;
        }
        char[] chars = s.toCharArray();
        StringBuilder sb = new StringBuilder();
        for (char aChar : chars) {
            if((aChar>='a' && aChar <='z') || (aChar>='A' && aChar <='Z')  || (aChar>='0' && aChar <='9')){
                sb.append(aChar);
            }
        }
        return sb.toString().equalsIgnoreCase(sb.reverse().toString());
    }

    public static void main(String[] args) {
        System.out.println(isPalindrome("A man, a plan, a canal: Panama"));
    }
}
